<template>
	<view class="bg">
		<image src="/static/login.png" mode="aspectFit"></image>
		<view class="txt deep">超值！创业项目-共享充电器</view>
		<view class="txt">低成本·高回报·低风险·高红利</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {}
		},
		onLoad(option) {
			console.log(option)
			let code = this.$utils.getQueryString(location.href,'code');
			if(code){
				//提现微信绑定也跳这里
				let state = this.$utils.getQueryString(location.href,'state');
				if('wallet_wx_add' == state){
					uni.redirectTo({
						 url: '../mine/wallet/way/wxBind?wxCode='+code
					});
				}else{
					//微信自动登陆
					this._wxLogin(code,state);
				}
			}else{
				let role = option.role || 0;
				let url = window.location.origin + window.location.pathname;
				let appId = this.$store.getters.GET_AppId;
				url = encodeURIComponent(url);
				window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appId
					+'&redirect_uri='+url
					+'&response_type=code&scope=snsapi_userinfo'
					+'&state='+role+'#wechat_redirect';
			}
		},
		methods: {
			_wxLogin:function(code,role){
				let appId = this.$store.getters.GET_AppId;
				const api = this.$request;
				const _self = this;
				api.post(api.url.wxLogin,{
					appId:appId,
					wxCode:code,
					role:role
				},(res)=>{
					if(res.code==200){
						_self.$store.commit('SET_userInfo',res.body)
						setTimeout(function(){
							_self.$common.toIndex();
						},1000)
					}else {
						uni.reLaunch({url:'/pages/login/wxLogin?role='+role})
					}
				})
			}
		}
	}
</script>

<style lang="less">
.bg{
	width: 100vw;
	height: 100vh;
	background-color: white;
	padding-top: 200rpx;
}
image{
	width: 600rpx;
	height: 600rpx;
	display: block;
	margin: 0rpx auto 180rpx;
}
.txt{
	text-align: center;
	color: #999;
	font-size: 32rpx;
}
.deep{
	font-size: 40rpx;
	color: #ff813b;
	font-weight: 600;
	margin-bottom: 28rpx;
}
</style>
